import Vue from 'vue'
import Router from 'vue-router'
//测试
import home from  './views/home.vue'
import index from './views/common/index.vue'
import store from './store.js'
import vueext from './extended/vueext'

Vue.use(vueext);
Vue.use(Router);
//登陆
import login from './views/login.vue'//登陆
import resetPWD from './views/common/resetPWD'//密码修改

//区县级数据填报
import areaFillvegetableBase from './views/Area/dataReport/vegetableBase'//1.(一)2017年蔬菜用地情况调查表(全面统计)
import areaFillFacilities from './views/Area/dataReport/facilities'//2.设施情况
import areaFillProduction from './views/Area/dataReport/Production.vue'//3.蔬菜生产情况季度调查表
import areaFillProductionYear from './views/Area/dataReport/ProductionYear.vue'//4.主要蔬菜播种面积、产量年度调查表
import areaFillSale from './views/Area/dataReport/sale.vue' //5.外销情况
import areaFillReportDoe from './views/Area/dataReport/Doe.vue'//6.蔬菜生产经营实体
import areaFillInstitutionPerson from './views/Area/dataReport/InstitutionPerson.vue'//7.蔬菜机构人员调查表
import areaFillGrowSeedle from './views/Area/dataReport/GrowSeedle'//8.蔬菜育苗专业化组织及生产能力
import areaFillColdStorage from './views/Area/dataReport/ColdStorage'//9.冷库


//州市级数据填报
import cityFillInstitutionPerson from './views/City/dataReport/InstitutionPerson.vue'//蔬菜机构人员调查表


//州市级数据审核
import cityReviewProduction from './views/City/review/production.vue'//主要蔬菜生产情况季度调查表
import cityReviewProductionYear from './views/City/review/productionYear.vue'//主要蔬菜播种面积、产量年度调查表
import cityReviewInstitutionPerson from './views/City/review/InstitutionPerson.vue'//人员机构审核
import cityReviewDoe from './views/City/review/Doe.vue'//生产经营实体审核
import cityReviewSale from './views/City/review/sale.vue'//外销量审核
import cityReviewfacilities from './views/City/review/facilities.vue'//蔬菜设施情况审核
import cityReviewVegetableBase from './views/City/review/vegetableBase.vue'//蔬菜基本情况审核
import cityFillGrowSeedle from './views/City/review/GrowSeedle'//8.蔬菜育苗专业化组织及生产能力
import cityFillColdStorage from './views/City/review/ColdStorage'//7.冷库

//填报管理
import ReportCreate from './views/ReportMng/ReportCreate.vue'//填报生成
import ReportSet from './views/ReportMng/ReportSet.vue'//填报设置

//系统设置
import dataDict from './views/system/dataDict.vue'//数据字典
import users from './views/system/users.vue'//系统用户
import logs from './views/system/logs.vue'//系统日志
import area from './views/system/area.vue'//行政区划管理
import role from './views/system/role.vue'//角色管理
import menu from './views/system/menu.vue'//菜单管理
import userinfo from './views/system/userinfo.vue'//菜单管理


//报表汇总
import statsVegetableBase from './views/stats/vegetableBase.vue'//(一)蔬菜用地情况调查表(全面统计)
import statsFacilities from './views/stats/facilities'//(二)蔬菜生产设施情况调查表(全面统计)
import statsProduction from './views/stats/Production.vue'//(三)主要蔬菜生产情况季度调查表(全面统计)
import statsProductionYear from './views/stats/ProductionYear.vue'//(四)主要蔬菜播种面积、产量年度调查表
import statsSale from './views/stats/sale.vue' //(五)蔬菜外销调查表(全面统计)
import statsVegGrowSeedle from './views/stats/VegGrowSeedle.vue' //(六)蔬菜育苗专业化组织及生产能力调查表(全面统计)
import statsVegColdStorag from './views/stats/VegColdStorag.vue' //(七)蔬菜冷库调查表(全面统计)
import statsDoe from './views/stats/Doe.vue'//(八)蔬菜生产经营实体及相关情况(全面统计)
import statsInstitutionPerson from './views/stats/InstitutionPerson.vue'//(九)蔬菜技术推广机构及人员情况统计表(全面统计)
//报表分析

//系统维护中
import gz from './views/common/gz.vue'//6.蔬菜机构人员调查表




const routes = [
		//默认地址	/*系统主页*/
		{ path: '/', redirect: '/home' },
		/*系统登录*/
		{path:'/login',name:'login',component:login},
		/*填报*/
		{path: '/home',name:'主页',component:home, meta: {
			icon:'ios-home-outline'
				},children:[
			//区县级数据填报
			{path:'/Area/fillVegetableBase',name:'(一)蔬菜用地情况调查表(全面统计)',component:areaFillvegetableBase},		 
			{path:'/Area/fillFacilities',name:'(二)蔬菜生产设施情况调查表(全面统计)',component:areaFillFacilities},		 
			{path:'/Area/fillProduction',name:'(三)主要蔬菜生产情况季度调查表(全面统计)',component:areaFillProduction},
			{path:'/Area/fillProductYear',name:'(四)主要蔬菜播种面积、产量年度调查表',component:areaFillProductionYear},
			{path:'/Area/fillSale',name:'(五)蔬菜外销调查表(全面统计)',component:areaFillSale},	
			{path:'/Area/fillVegGrowSeedle',name:'(六)蔬菜育苗专业化组织及生产能力调查表(全面统计)',component:areaFillGrowSeedle},	
			{path:'/Area/fillVegColdStorage',name:'(七)蔬菜冷库调查表(全面统计)',component:areaFillColdStorage},
			{path:'/Area/fillDoe',name:'(八)蔬菜生产经营实体及相关情况(全面统计)',component:areaFillReportDoe},
			{path:'/Area/fillInstitutionPerson',name:'(九)蔬菜技术推广机构及人员情况统计表(全面统计)',component:areaFillInstitutionPerson},
	

			//州市级数据填报
			{path:'/City/fillInstitutionPerson',name:'(九)蔬菜技术推广机构及人员情况统计表(全面统计)_填报',component:cityFillInstitutionPerson},
			//州市级审核
			{path:'/City/reviewVegetableBase',name:'(一)蔬菜用地情况调查表(全面统计)_审核',component:cityReviewVegetableBase},			
			{path:'/City/reviewfacilities',name:'(二)蔬菜生产设施情况调查表(全面统计)_审核',component:cityReviewfacilities},
			{path:'/City/reviewProduction',name:'(三)主要蔬菜生产情况季度调查表(全面统计)_审核',component:cityReviewProduction},
			{path:'/City/reviewProductionYear',name:'(四)主要蔬菜播种面积、产量年度调查表(全面统计)_审核',component:cityReviewProductionYear},
			{path:'/City/reviewSale',name:'(五)蔬菜外销调查表(全面统计)_审核',component:cityReviewSale},	
			{path:'/City/reviewVegGrowSeedle',name:'(六)蔬菜育苗专业化组织及生产能力调查表(全面统计)_审核',component:cityFillGrowSeedle},	
			{path:'/City/reviewVegColdStorage',name:'(七)蔬菜冷库调查表(全面统计)_审核',component:cityFillColdStorage},		
			{path:'/City/reviewDoe',name:'(八)蔬菜生产经营实体及相关情况(全面统计)_审核',component:cityReviewDoe},
			{path:'/City/reviewInstitutionPerson',name:'(九)蔬菜技术推广机构及人员情况统计表(全面统计)_审核',component:cityReviewInstitutionPerson},

			//密码修改
			{path:'/home/resetPWD',component:resetPWD},
			//报表管理
			{path:'/ReportMng/ReportCreate',name:'填报生成',meta:{icon:'social-buffer',IconSize:20,FontSize:20},component:ReportCreate},
			{path:'/ReportMng/ReportSet',name:'填报设置',meta:{icon:'settings',IconSize:20,FontSize:20},component:ReportSet},			
			//系统设置
			{path:'/dataDict' ,name:'数据字典管理',meta:{icon:'gear-b',IconSize:20,FontSize:20} ,component:dataDict},//数据字典
			{path:'/users',name:'用户管理',meta:{icon:'person-stalker',IconSize:20,FontSize:20} ,component:users},//用户管理
			{path:'/logs' ,name:'日志管理',meta:{icon:'clipboard',IconSize:20,FontSize:20} ,component:logs},//日志管理	
			{path:'/menu' ,name:'菜单管理',meta:{icon:'android-menu',IconSize:20,FontSize:20} ,component:menu},//菜单管理	
			{path:'/role' ,name:'角色管理',meta:{icon:'briefcase',IconSize:20,FontSize:20} ,component:role},//角色管理	
			{path:'/area' ,name:'行政区划管理',meta:{icon:'map',IconSize:20,FontSize:20} ,component:area},//行政区划管理	
			{path:'/sys/userinfo' ,name:'个人信息维护',meta:{icon:'person-stalker',IconSize:20,FontSize:20} ,component:userinfo},//行政区划管理		 
			//默认主页
			{path:'/home/',component:index},
			//数据汇总
			{path:'/stats/VegetableBase',name:'(一)蔬菜用地情况调查表(全面统计)_汇总',component:statsVegetableBase},//(一)蔬菜用地情况调查表(全面统计)_汇总
			{path:'/stats/Facilities',name:'(二)蔬菜生产设施情况调查表(全面统计)_汇总',component:statsFacilities},//(二)蔬菜生产设施情况调查表(全面统计)_汇总
			{path:'/stats/Production',name:'(三)主要蔬菜生产情况季度调查表(全面统计)_汇总',component:statsProduction},//(三)主要蔬菜生产情况季度调查表(全面统计)_汇总
			{path:'/stats/ProductionYear',name:'(四)主要蔬菜播种面积、产量年度调查表(全面统计)_汇总',component:statsProductionYear},//(四)主要蔬菜播种面积、产量年度调查表(全面统计)_汇总
			{path:'/stats/Sale',name:'(五)蔬菜外销调查表(全面统计)_汇总',component:statsSale},//(五)蔬菜外销调查表(全面统计)_汇总
			{path:'/stats/VegGrowSeedle',name:'(六)蔬菜育苗专业化组织及生产能力调查表(全面统计)_汇总',component:statsVegGrowSeedle},//(六)蔬菜育苗专业化组织及生产能力调查表(全面统计)_汇总
			{path:'/stats/VegColdStorag',name:'(七)蔬菜冷库调查表(全面统计)_汇总',component:statsVegColdStorag},//(七)蔬菜冷库调查表(全面统计)_汇总
			{path:'/stats/Doe',name:'(八)蔬菜生产经营实体及相关情况(全面统计)_汇总',component:statsDoe},//(八)蔬菜生产经营实体及相关情况(全面统计)_汇总
			{path:'/stats/InstitutionPerson',name:'(九)蔬菜技术推广机构及人员情况统计表(全面统计)_汇总',component:statsInstitutionPerson}//(九)蔬菜技术推广机构及人员情况统计表(全面统计)_汇总
			]
		}
	];

	let router = new Router({
        history: true,
        routes:routes
});
// 全局 before 钩子: 进入下一个路由前， 修改 Vuex 中的 breadcrumb 内容
	router.beforeEach((to, from, next) => {
		var user = Vue.prototype.GetlocaStorage("VegUserInfo");
		var userActions=Vue.prototype.GetlocaStorage("useractionlist");
		if (to.name !== 'login') {
			if (user !== null) {
				if (to.path !== '/home') {
					//面包削数据更新
					var BreadcrumbItem = new Object();
					BreadcrumbItem.RouterName = to.name;
					BreadcrumbItem.RouterUrl = to.path;
					BreadcrumbItem.RouterIcon = to.meta.icon;
					store.dispatch('updateBreadcrumb', BreadcrumbItem);
					//用户操作按钮权限列表数据更新
					var actionInfo=new Object();
					actionInfo.path=to.path;
					actionInfo.account=user.Account;
					actionInfo.list=userActions;
					store.dispatch('setActionList', actionInfo);
				} else {
					store.dispatch('desBreadcrumb');
				}
				next();
			} else {
				next({path: '/login'});
			}
		} else {
			next();
		}
	})
export default router;